home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / dev / amos / KyzerAMOScode.lha / CopDis.AMOS / CopDis.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-03  |  7.0 KB  |  174 lines

  1. ' copperlist disassembly/save/both routines by Kyzer/CSG 30/1/96 
  2. '
  3. ' NOTES: If you get a "MOVE #$xxxx,$xxxx" as opposed to a
  4. ' "MOVE #$xxxx,regname" then A) the copperlist is not a copperlist, B) the 
  5. ' copperlist is damaged or C) some nutter thinks writing to undefined
  6. ' registers is cool. If nothing is printed/saved then tough luck! The
  7. ' copperlist doesn't end with a $FFFFFFFE like it should! Oh, and 151404 
  8. ' bytes is the theoretic maximum length of a copperlist, but in reality
  9. ' it's impossible. 
  10. '
  11. ' Demo of usage: 
  12. Screen Open 0,640,256,4,Hires
  13. Screen Display 0,128,48,640,256
  14. ' ^ first, open a hires screen for fun 
  15. '
  16. FINDMAINCOP : ADR=Param
  17. ' ^ get address of the AMOS master copperlist
  18. '
  19. COPDIS[ADR]
  20. ' ^ disassemble the copperlist to the screen.  
  21. '   press any key to pause, then any key to continue 
  22. '  
  23. COPDIS_SAVE[ADR,"ram:copperlist1.txt"]
  24. ' ^ and disassemble again, but to the file "ram:copperlist1.txt" 
  25. '
  26. COPSAVE[ADR,"ram:copperlist1.bin"]
  27. ' ^ save the copperlist as raw data
  28. '
  29. NAMEREG[$92] : A$=Param$
  30. ' ^ get name of register $92 (it's ddfstrt, btw :) 
  31. '
  32. FINDCOPVALUE[ADR,$92] : A=Param
  33. Print A$;" =";A
  34. ' ^ find ddfstrt value in the copperlist, and print it 
  35. '
  36. End 
  37. '
  38. Procedure COPDIS[COPLIST]
  39.    ' disassembles a copper list to screen 
  40.    '
  41.    CEND=$FFFFFFFE : CL=COPLIST
  42.    ADR=CL-4 : Repeat : Add ADR,4 : Until Leek(ADR)=CEND or(ADR-CL)>151404
  43.    If Leek(ADR)<>CEND Then Pop Proc
  44.    Repeat 
  45.       If Inkey$<>"" Then Wait Key 
  46.       INST=Leek(CL) : Add CL,4
  47.       If Btst(16,INST)
  48.          WA=INST : WB=INST : WC=INST : WD=INST
  49.          Rol.l 8,WA : Rol.l 16,WB
  50.          WA=WA and 255 : WB=WB and 255 : WC=WC and 65535
  51.          A$="x="+Str$(WB)+",y="+Str$(WA)
  52.          If INST=CEND
  53.             Print Hex$(INST);": CEND"
  54.          Else 
  55.          If Btst(0,WC) : C$="SKIP" Else C$="WAIT" : End If 
  56.             Print Hex$(INST);": ";C$;"  ";A$-" "+"  (mask="+(Hex$(WC)-" ")+")"
  57.          End If 
  58.       Else 
  59.          MA=INST : MB=INST : Rol.l 16,MA
  60.          MA=MA and 65535 : MB=MB and 65535
  61.          NAMEREG[MA] : MA$=Param$
  62.          If MA$=""
  63.             Print Hex$(INST,8);": MOVE  #";Hex$(MB);",";Hex$(MA)
  64.          Else 
  65.             Print Hex$(INST,8);": MOVE  #";Hex$(MB);",";MA$
  66.          End If 
  67.       End If 
  68.    Until INST=CEND
  69. End Proc
  70. Procedure COPDIS_SAVE[COPLIST,FILENAME$]
  71.    ' disassembles a copper list to a file 
  72.    '
  73.    CEND=$FFFFFFFE : CL=COPLIST
  74.    ADR=CL-4 : Repeat : Add ADR,4 : Until Leek(ADR)=CEND or(ADR-CL)>151404
  75.    If Leek(ADR)<>CEND Then Pop Proc
  76.    Open Out 1,FILENAME$ : N$=Chr$(10)
  77.    Repeat 
  78.       INST=Leek(CL) : Add CL,4
  79.       If Btst(16,INST)
  80.          WA=INST : WB=INST : WC=INST : WD=INST
  81.          Rol.l 8,WA : Rol.l 16,WB
  82.          WA=WA and 255 : WB=WB and 255 : WC=WC and 65535
  83.          A$="x="+Str$(WB)+",y="+Str$(WA)
  84.          If INST=CEND
  85.             Print #1,Hex$(INST);": CEND";N$;
  86.          Else 
  87.          If Btst(0,WC) : C$="SKIP" Else C$="WAIT" : End If 
  88.             Print #1,Hex$(INST);": ";C$;"  ";A$-" "+"  (mask="+(Hex$(WC)-" ")+")";N$;
  89.          End If 
  90.       Else 
  91.          MA=INST : MB=INST : Rol.l 16,MA
  92.          MA=MA and 65535 : MB=MB and 65535
  93.          NAMEREG[MA] : MA$=Param$
  94.          If MA$=""
  95.             Print #1,Hex$(INST,8);": MOVE  #";Hex$(MB);",";Hex$(MA);N$;
  96.          Else 
  97.             Print #1,Hex$(INST,8);": MOVE  #";Hex$(MB);",";MA$;N$;
  98.          End If 
  99.       End If 
  100.    Until INST=CEND
  101.    Close 1
  102. End Proc
  103. Procedure FINDMAINCOP
  104.    ' gets main copper address 
  105.    '
  106.    Copper Off 
  107.    ADR=Cop Logic
  108.    Copper On 
  109. End Proc[ADR]
  110. Procedure COPSAVE[COPLIST,FILENAME$]
  111.    ' saves off a copperlist 
  112.    '
  113.    CEND=$FFFFFFFE : CL=COPLIST
  114.    ADR=CL-4 : Repeat : Add ADR,4 : Until Leek(ADR)=CEND or(ADR-CL)>151404
  115.    If Leek(ADR)<>CEND Then Pop Proc
  116.    Bsave FILENAME$,COPLIST To ADR+4
  117. End Proc
  118. Procedure FINDCOPVALUE[COPLIST,REG]
  119.    ' gets the value a register is set to in the coplist (or -1 if not found)  
  120.    '
  121.    CEND=$FFFFFFFE : CL=COPLIST
  122.    REG=REG and %111111110
  123.    ADR=CL-4 : Repeat : Add ADR,4 : Until Leek(ADR)=CEND or(ADR-CL)>151404
  124.    If Leek(ADR)<>CEND Then Pop Proc
  125.    NUM=-1
  126.    Repeat : INST=Leek(CL) : Add CL,4 : If Btst(16,INST)=0 : A=INST
  127.    Rol.l 16,A : A=A and %111111110 : If A=REG : NUM=INST and $FFFF : End If 
  128.    End If : Until INST=CEND or NUM<>-1
  129. End Proc[NUM]
  130. Procedure NAMEREG[REG]
  131.    ' puts a name to a register (or "" if it doesn't exist)
  132.    NAME$=""
  133.    REG=REG/2
  134.    If REG>255 Then Pop Proc
  135.    Restore 
  136.    For A=0 To REG : Read NAME$ : Next A
  137.    Rem Generated from V40 hardware/custom.i 
  138.    Data "bltddat","dmaconr","vposr","vhposr","dskdatr","joy0dat","joy1dat"
  139.    Data "clxdat","adkconr","pot0dat","pot1dat","potinp","serdatr","dskbytr"
  140.    Data "intenar","intreqr","dskpth","dskptl","dsklen","dskdat","refptr"
  141.    Data "vposw","vhposw","copcon","serdat","serper","potgo","joytest","strequ"
  142.    Data "strvbl","strhor","strlong","bltcon0","bltcon1","bltafwm","bltalwm"
  143.    Data "bltcpth","bltcptl","bltbpth","bltbptl","bltapth","bltaptl","bltdpth"
  144.    Data "bltdptl","bltsize","bltcon0l","bltsizv","bltsizh","bltcmod","bltbmod"
  145.    Data "bltamod","bltdmod","","","","","bltcdat","bltbdat","bltadat",""
  146.    Data "sprhdat","bplhdat","lisaid","dsksync","cop1lch","cop1lcl","cop2lch"
  147.    Data "cop2lcl","copjmp1","copjmp2","copins","diwstrt","diwstop","ddfstrt"
  148.    Data "ddfstop","dmacon","clxcon","intena","intreq","adkcon","aud0lch"
  149.    Data "aud0lcl","aud0len","aud0per","aud0vol","aud0dat","","","aud1lch"
  150.    Data "aud1lcl","aud1len","aud1per","aud1vol","aud1dat","","","aud2lch"
  151.    Data "aud2lcl","aud2len","aud2per","aud2vol","aud2dat","","","aud3lch"
  152.    Data "aud3lcl","aud3len","aud3per","aud3vol","aud3dat","","","bpl1pth"
  153.    Data "bpl1ptl","bpl2pth","bpl2ptl","bpl3pth","bpl3ptl","bpl4pth","bpl4ptl"
  154.    Data "bpl5pth","bpl5ptl","bpl6pth","bpl6ptl","bpl7pth","bpl7ptl","bpl8pth"
  155.    Data "bpl8ptl","bplcon0","bplcon1","bplcon2","bplcon3","bpl1mod","bpl2mod"
  156.    Data "bplcon4","clxcon2","bpl1dat","bpl2dat","bpl3dat","bpl4dat","bpl5dat"
  157.    Data "bpl6dat","bpl7dat","bpl8dat","spr0pth","spr0ptl","spr1pth","spr1ptl"
  158.    Data "spr2pth","spr2ptl","spr3pth","spr3ptl","spr4pth","spr4ptl","spr5pth"
  159.    Data "spr5ptl","spr6pth","spr6ptl","spr7pth","spr7ptl","spr0pos","spr0ctl"
  160.    Data "spr0data","spr0datb","spr1pos","spr1ctl","spr1data","spr1datb"
  161.    Data "spr2pos","spr2ctl","spr2data","spr2datb","spr3pos","spr3ctl"
  162.    Data "spr3data","spr3datb","spr4pos","spr4ctl","spr4data","spr4datb"
  163.    Data "spr5pos","spr5ctl","spr5data","spr5datb","spr6pos","spr6ctl"
  164.    Data "spr6data","spr6datb","spr7pos","spr7ctl","spr7data","spr7datb"
  165.    Data "color00","color01","color02","color03","color04","color05","color06"
  166.    Data "color07","color08","color09","color10","color11","color12","color13"
  167.    Data "color14","color15","color16","color17","color18","color19","color20"
  168.    Data "color21","color22","color23","color24","color25","color26","color27"
  169.    Data "color28","color29","color30","color31","htotal","hsstop","hbstrt"
  170.    Data "hbstop","vtotal","vsstop","vbstrt","vbstop","sprhstrt","sprhstop"
  171.    Data "bplhstrt","bplhstop","hhposw","hhposr","beamcon0","hsstrt","vsstrt"
  172.    Data "hcenter","diwhigh","bplhmod","sprhpth","sprhptl","bplhpth","bplhptl"
  173.    Data "","","","","","","fmode","noop"
  174. End Proc[NAME$]